/**
 * Copyright &copy; 2012-2016
 * <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights
 * reserved.
 */
package com.thinkgem.jeesite.modules.shop.entity.order;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.validation.constraints.NotNull;

import org.apache.ibatis.type.Alias;
import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.thinkgem.jeesite.common.persistence.DataEntity;
import com.thinkgem.jeesite.modules.accountinfo.entity.AccountInfo;
import com.thinkgem.jeesite.modules.shop.entity.info.ShopOrderInfo;
import com.thinkgem.jeesite.modules.shop.entity.operate.ShopOrderOperate;
import com.thinkgem.jeesite.modules.shop.entity.receipt.ShopOrderReceipt;
import com.thinkgem.jeesite.modules.shop.entity.receiving.ShopOrderReceiving;

/**
 * 购物订单Entity
 * 
 * @author JiangYongKang
 * @version 2016-12-19
 */
@Alias("shopOrder")
public class ShopOrder extends DataEntity<ShopOrder> {

    private static final long serialVersionUID = 1L;

    private String code; // 订单编号

    private Double totalAmount; // 订单总金额
    
    private BigDecimal formatTotalAmount; // 订单总金额

    private Double totalAmountProduct; // 商品总金额
    
    private BigDecimal formatTotalAmountProduct; // 商品总金额

    private Double freight; // 配送费  
    
    private BigDecimal formatFreight;

    private Date createTime; // 订单创建时间

    private Date payTime; // 订单支付时间

    private Short status; // 订单状态

    private String comment; // 备注信息
    
    private String bankId; // 支付方式

    private String accountId; // 用户ID

    private AccountInfo account; // 用户
    
    private short isDeleted;
    
    private String refundReason; // 退款理由

    private ShopOrderReceiving shopOrderReceiving; // 收货方式

    private ShopOrderReceipt shopOrderReceipt; // 发票信息

    private List<ShopOrderInfo> shopOrderInfoList; // 订单信息

    private List<ShopOrderOperate> shopOrderOperateList; // 操作记录

    public ShopOrder() {
        super();
    }

    public ShopOrder(String id) {
        super(id);
    }

    @Length(min = 1, max = 64, message = "订单编号长度必须介于 1 和 64 之间")
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Double getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(Double totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getFormatTotalAmount() {
    	return new BigDecimal(getTotalAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
	}

	public void setFormatTotalAmount(BigDecimal formatTotalAmount) {
		this.formatTotalAmount = new BigDecimal(getTotalAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
	}
    
    public Double getTotalAmountProduct() {
        return totalAmountProduct;
    }
	
    public void setTotalAmountProduct(Double totalAmountProduct) {
        this.totalAmountProduct = totalAmountProduct;
    }

    public BigDecimal getFormatTotalAmountProduct() {
    	return new BigDecimal(getTotalAmountProduct()).setScale(2, BigDecimal.ROUND_HALF_UP);
	}

	public void setFormatTotalAmountProduct(BigDecimal formatTotalAmountProduct) {
		this.formatTotalAmountProduct =new BigDecimal(getTotalAmountProduct()).setScale(2, BigDecimal.ROUND_HALF_UP);
	}

	public Double getFreight() {
        return freight;
    }

    public void setFreight(Double freight) {
        this.freight = freight;
    }
    

    public BigDecimal getFormatFreight() {
		return new BigDecimal(getFreight()).setScale(2, BigDecimal.ROUND_HALF_UP);
	}

	public void setFormatFreight(BigDecimal formatFreight) {
		this.formatFreight = new BigDecimal(getFreight()).setScale(2, BigDecimal.ROUND_HALF_UP);
	}

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getPayTime() {
        return payTime;
    }

    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }

    @NotNull(message = "用户ID不能为空")
    public AccountInfo getAccount() {
        return account;
    }

    public void setAccount(AccountInfo account) {
        this.account = account;
    }

    @Length(min = 1, max = 4, message = "订单状态长度必须介于 1 和 4 之间")
    public Short getStatus() {
        return status;
    }

    public void setStatus(Short status) {
        this.status = status;
    }

    @Length(min = 0, max = 255, message = "备注信息长度必须介于 0 和 255 之间")
    public String getComment() {
        return comment;
    }


	public String getBankId() {
		return bankId;
	}

	public void setBankId(String bankId) {
		this.bankId = bankId;
	}

	public void setComment(String comment) {
        this.comment = comment;
    }

    public String getRefundReason() {
		return refundReason;
	}

	public void setRefundReason(String refundReason) {
		this.refundReason = refundReason;
	}

	public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public ShopOrderReceiving getShopOrderReceiving() {
        return shopOrderReceiving;
    }

    public void setShopOrderReceiving(ShopOrderReceiving shopOrderReceiving) {
        this.shopOrderReceiving = shopOrderReceiving;
    }

    public ShopOrderReceipt getShopOrderReceipt() {
        return shopOrderReceipt;
    }

    public void setShopOrderReceipt(ShopOrderReceipt shopOrderReceipt) {
        this.shopOrderReceipt = shopOrderReceipt;
    }

    public List<ShopOrderInfo> getShopOrderInfoList() {
        return shopOrderInfoList;
    }

    public void setShopOrderInfoList(List<ShopOrderInfo> shopOrderInfoList) {
        this.shopOrderInfoList = shopOrderInfoList;
    }

    public List<ShopOrderOperate> getShopOrderOperateList() {
        return shopOrderOperateList;
    }

    public void setShopOrderOperateList(
            List<ShopOrderOperate> shopOrderOperateList) {
        this.shopOrderOperateList = shopOrderOperateList;
    }

	public short getIsDeleted() {
		return isDeleted;
	}

	public void setIsDeleted(short isDeleted) {
		this.isDeleted = isDeleted;
	}

}